package com.knowledge.review.designPatterns.structuralpattern.adapterclass;

import lombok.AllArgsConstructor;

// 电源接口
interface Power1 {
    int output();
}
// 适配者 220V电压
class AC2201 implements Power1 {
    @Override
    public int output() {
        System.out.println("输出220V交流电");
        return 220;
    }
}
// 目标 5V
interface DC51 {
    int output5();
}
@AllArgsConstructor
class PowerAdapter1 implements DC51 {
 
    // 适配者
    private Power1 power;
    @Override
    public int output5() {
        int output220 = power.output();
        int output5 = output220 / 44;
        System.out.println(output220 + "V适配转换成" + output5 + "V");
        return output5;
    }
}

class TestObjectAdapter{
    // 测试
    public static void main(String[] args) {
        DC51 powerAdapter = new PowerAdapter1(new AC2201());
        // 输出220V交流电
        // 220V适配转换成5V
        powerAdapter.output5();
    }
}